package com.elab.web;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.elab.model.BaseResponse;


@RestController
@RequestMapping(value = {"user", "u"})
public class userController {
	protected Logger logger = LogManager.getLogger(getClass());
	@RequestMapping(value = {"login"}, method = {RequestMethod.GET, RequestMethod.POST})
	BaseResponse login (String username, String password) {
		logger.info("login: " + username + " / " + password);
		JSONObject user = new JSONObject();
		user.put("username", username);
		user.put("password", password);
		logger.info("" + user.toJSONString());
		/*try {
			if(username != null) {
				throw new Exception("test exception");
			}
		} catch (Exception e) {
			 e.printStackTrace();
			return BaseResponse.fail(500,"test Exception", user );
		}*/
		return BaseResponse.ok("test", user );
	}
}
